<?

if (!permitted('configure', $node = (int)param('node'))) {
	header("Location: "._transformURL($CURRENT->url, array('remove_params' => 'all', 'add_param' => "node:$node")));
	exit;
}

$DATA['components'] = array();

if (($temp = @glob($_SERVER['DOCUMENT_ROOT'].FP_COMPONENT_PATH.'*', GLOB_ONLYDIR)) && sizeof($temp)) {
	foreach ($temp as $t)
		$DATA['components'][] = substr(strrchr($t, "/"), 1);
}

if (($c = (int)param('settings')) && ($temp = datafetch('db_item', tb('data'), "id_data=".D_MULTIBLOCK." AND id_parent in (".$DATA['page']['id'].", 0) AND id=$c")) && in_array($temp['value'], $DATA['components'])) {
	
	$DATA['component'] = array_merge($temp, array('path' => $_SERVER['DOCUMENT_ROOT'].FP_COMPONENT_PATH.$temp['value']));
	
	if (file_exists("{$DATA[component][path]}/admin/settings/init.php")) {
		
		$temp = $CURRENT->getPageById($node);	// !!! fix crumbs

		$DATA['crumb'][] = array(
			'name' => $temp['localname'] ? $temp['localname'] : $temp['name'],
			'path' => _transformURL($CURRENT->url, array('remove_params' => 'all', 'add_param' => "node:$node")));
		$DATA['crumb'][] = array('name' => 'Настройки');
		$DATA['crumb'] = array_mark_bounds($DATA['crumb']);

		if (include("{$DATA[component][path]}/admin/settings/init.php")) {	// end of component edition
			header("Location: "._transformURL($CURRENT->url, array('remove_param' => 'settings')));
			exit;
		}
	}

} else {	// **** no such component ****

	header("Location: "._transformURL($CURRENT->url, array('remove_param' => 'settings')));
	exit;
}

?>